﻿using Microsoft.AspNetCore.SignalR;
using PLCS.Application.EquipmentApp.Hubs;
using PLCS.Domain.Shared.Equipments;

namespace PLCS.Web.EventHandlers;

public class RGVLocationChangeHandler : ILocalEventHandler<RGVCCurrentStationhangeEvent>, ITransientDependency
{
    private readonly IHubContext<FrameHub> _hubcontext;

    public RGVLocationChangeHandler(IHubContext<FrameHub> hubcontext)
    {
        _hubcontext = hubcontext;
    }

    public async Task HandleEventAsync(RGVCCurrentStationhangeEvent eventData)
    {
        await _hubcontext.Clients.All.SendAsync("ChangeEquipmentLocation", eventData.Name, eventData.StationName);
    }
}